package com.qing.springcloud.controller;

import com.qing.springcloud.annotation.RequireLogin;
import com.qing.springcloud.annotation.ResponseResult;
import com.qing.springcloud.dto.friend.FriendRequestDTO;
import com.qing.springcloud.dto.friend.HandleFriendRequestDTO;
import com.qing.springcloud.dto.user.UserDTO;
import com.qing.springcloud.service.FriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author caozhipeng
 * @date 2025/7/21
 */
@RestController
@RequestMapping("/friend")
@ResponseResult
@RequireLogin
public class FriendController {
    @Autowired
    private FriendService friendService;

    //    发送添加好友请求
    @PostMapping("/sendFriendRequest")
    public void sendFriendRequest(@RequestBody FriendRequestDTO dto){
        friendService.sendFriendRequest(dto);
    }
    //    处理好友请求
    @PostMapping("/handleFriendRequest")
    public void handleFriendRequest(@RequestBody HandleFriendRequestDTO dto){
        friendService.handleFriendRequest(dto);
    }
    //    删除好友
    @PostMapping("/deleteFriend")
    public void deleteFriend(@RequestParam("userId") Long userId, @RequestParam("friendId") Long friendId){
        friendService.deleteFriend(userId, friendId);
    }
    //    获取好友列表
    @GetMapping("/getFriendList")
    public  List<UserDTO> getFriendList( @RequestParam("userId") Long userId){
        return friendService.getFriendList(userId);
    }
    //    拉黑好友
    @PostMapping("/blacklistFriend")
    public void blacklistFriend(@RequestParam("userId") Long userId, @RequestParam("friendId") Long friendId){
        friendService.blacklistFriend(userId, friendId);
    }


}
